﻿using HBase;
using hCommand;
using System.Collections.Generic;


namespace hCommand {
    public abstract class TaskBackTask :ZtTask {

        public TaskBackTask() {
            time = 3600 * 1000 * 12;
        }

        public IMServer mServer = GuidangFactray.getDal<IMServer>();
        public ICoreTaskServer taskServer = WMSDalFactray.getDal<ICoreTaskServer>();



        public void backTask(long stockId) {
            List<CoreTask> ctList = taskServer.getTasksByStockId(stockId);
            deleteTasks(ctList);
        }

        public void deleteTasks(List<CoreTask> ctList) {
            foreach( CoreTask ct in ctList ) {
                List<CoreTaskParam> paramList = taskServer.getTaskParamByTaskId(ct.id);
                foreach( CoreTaskParam p in paramList ) {
                    back(p);
                }
                back(ct);
            }
        }

        public void back(BaseEntity e) {
            mServer.backUp(e);
            taskServer.delete(e);
        }

    }
}
